﻿using System;
using System.Runtime.Serialization;

namespace SharpRomans.Exceptions
{
	[Serializable]
	public class ParseException : Exception
	{
		//
		// For guidelines regarding the creation of new exception types, see
		//    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
		// and
		//    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
		//

		public ParseException() { }

		public ParseException(string message) : base(message) { }

		public ParseException(string message, Exception inner) : base(message, inner) { }

		protected ParseException(SerializationInfo info, StreamingContext context) : base(info, context) { }

		public ParseException(string literal, int index) : base(
			string .Format("Error parsing string \"{0}\" in character '{1}' in position {2}", literal, literal[index], index))
		{
			CharacterNumber = index;
			Character = literal[index];
		}

		public int CharacterNumber { get; private set; }

		public char Character { get; private set; }
	}
}
